clear all;
close all;
clc;

m = -1; # Coordinate System
FiMAX=40; # Max iteration steps
Qnotation_m = 1;
Qnotation_n = 6; #Q-format parameters

if (m == -1)
	Fi = ones(1, FiMAX);
	tRep = 4;
	for i = 1 : (FiMAX - 1)
		if (Fi(i) == tRep)
			Fi(i + 1) = tRep;
			tRep = 3 .* tRep + 1;
		else
			Fi(i + 1) = Fi(i) + 1;
		endif
	endfor
	clear tRep;
	alphai = atanh(2 .^ (-1 .* Fi));
	Ki = sqrt(1 - 2.^ (-2 .* Fi));
elseif (m == 0)
	Fi = 1 : 1 : FiMAX;
	alphai = 2 .^  (-1 .* Fi);
	Ki = ones(1, FiMAX);
elseif (m == 1)
	Fi = 0 : 1: (FiMAX - 1);
	alphai = atan(2 .^ (-1 .* Fi));
	Ki = sqrt(1 + 2 .^ (-2 .* Fi));
endif;

alphai_norm = alphai .* (2 .^ (Qnotation_n));
alphai_norm_round = round(alphai_norm);
K_norm = prod(Ki) .* (2 .^ (Qnotation_n));
K_norm_round = round(K_norm);


format hex;
alphai_norm_round_hex = int8(alphai_norm_round) #Modify this line in order to get correct bits representations.
K_norm_round_hex = int8(K_norm_round) #Modify this line in order to get correct bits representations.
format long;